home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ccdl151e.zip / STDIO.H < prev    next >
C/C++ Source or Header  |  1997-04-08  |  7KB  |  198 lines

  1. /*  stdio.h
  2.  
  3.     Definitions for stream input/output.
  4.  
  5. */
  6.  
  7. #ifndef __STDIO_H
  8. #define __STDIO_H
  9.  
  10. #ifndef NULL
  11. #define NULL 0
  12. #endif
  13.  
  14. #ifndef _SIZE_T
  15. #define _SIZE_T
  16. typedef unsigned size_t;
  17. #endif
  18.  
  19. typedef long    fpos_t;
  20.  
  21. #define FILTOK    0x444c
  22. #define STACKPAD 512
  23.  
  24. /*  "flags" bits definitions
  25. */
  26. #define _F_RDWR 0x0003                  /* Read/write flag       */
  27. #define _F_READ 0x0001                  /* Read only file        */
  28. #define _F_WRIT 0x0002                  /* Write only file       */
  29. #define _F_BUF  0x0004                  /* Malloc'ed Buffer data */
  30. #define _F_LBUF 0x0008                  /* line-buffered file    */
  31. #define _F_ERR  0x0010                  /* Error indicator       */
  32. #define _F_EOF  0x0020                  /* End of file indicator */
  33. #define _F_BIN  0x0040                  /* Binary file indicator */
  34. #define _F_IN   0x0080                  /* Data is incoming      */
  35. #define _F_OUT  0x0100                  /* Data is outgoing      */
  36. #define _F_TERM 0x0200                  /* File is a terminal    */
  37. #define _F_SKIPLF 0x400            /* Need to skip next LF  */
  38. /* End-of-file constant definition
  39. */
  40. #define EOF (-1)            /* End of file indicator */
  41.  
  42. /* Default buffer size use by "setbuf" function
  43. */
  44. #define BUFSIZ  512         /* Buffer size for stdio */
  45.  
  46. /* Size of an arry large enough to hold a temporary file name string
  47. */
  48. #define L_ctermid   5       /* CON: plus null byte */
  49. #define P_tmpdir    ""      /* temporary directory */
  50. #define L_tmpnam    13      /* tmpnam buffer size */
  51.  
  52. /* Constants to be used as 3rd argument for "fseek" function
  53. */
  54. #define SEEK_CUR    1
  55. #define SEEK_END    2
  56. #define SEEK_SET    0
  57.  
  58. /* Number of unique file names that shall be generated by "tmpnam" function
  59. */
  60. #define TMP_MAX     0xFFFF
  61.  
  62. #define _NFILE_ 20
  63. /* Definition of the control structure for streams
  64. */
  65. typedef struct  {
  66.         int             level;          /* fill/empty level of buffer */
  67.         unsigned        flags;          /* File status flags          */
  68.         char            fd;             /* File descriptor            */
  69.         unsigned char   hold;           /* Ungetc char if no buffer   */
  70.         int             bsize;          /* Buffer size                */
  71.         unsigned char   *buffer;   /* Data transfer buffer       */
  72.         unsigned char   *curp;     /* Current active pointer     */
  73.         unsigned        istemp;         /* Temporary file indicator   */
  74.         short           token;          /* Used for validity checking */
  75. }       FILE;                           /* This is the FILE object    */
  76.  
  77. /* Number of files that can be open simultaneously
  78. */
  79. #define FOPEN_MAX (_NFILE_ - 2) /* (_NFILE_ - stdaux & stdprn) */
  80.  
  81. #define FILENAME_MAX 80
  82.  
  83. /* Standard I/O predefined streams
  84. */
  85.  
  86. extern  FILE     *_pstreams[];  /* Oops! Something ain't right! */
  87. extern  unsigned     _nfile;
  88.  
  89. #define _IOFBF  1
  90. #define _IOLBF  2
  91. #define _IONBF  4
  92.  
  93. #define stdin   (_pstreams[0])
  94. #define stdout  (_pstreams[1])
  95. #define stderr  (_pstreams[2])
  96. #define stdaux  (_pstreams[3])
  97. #define stdprn  (_pstreams[4])
  98.  
  99. void              clearerr(FILE *__stream);
  100. int       fclose(FILE *__stream);
  101. int       fflush(FILE *__stream);
  102. int       fgetc(FILE *__stream);
  103. int               fgetpos(FILE *__stream, fpos_t *__pos);
  104. char   *  fgets(char *__s, int __n, FILE *__stream);
  105. FILE   *  fopen(const char *__path, const char *__mode);
  106. int       fprintf(FILE *__stream, const char *__format, ...);
  107. int       fputc(int __c, FILE *__stream);
  108. int       fputs(const char *__s, FILE *__stream);
  109. size_t    fread(void *__ptr, size_t __size, size_t __n,
  110.                      FILE *__stream);
  111. FILE   *  freopen(const char *__path, const char *__mode,
  112.                             FILE *__stream);
  113. int       fscanf(FILE *__stream, const char *__format, ...);
  114. int       fseek(FILE *__stream, long __offset, int __whence);
  115. int               fsetpos(FILE *__stream, const fpos_t *__pos);
  116. long      ftell(FILE *__stream);
  117. size_t    fwrite(const void *__ptr, size_t __size, size_t __n,
  118.                       FILE *__stream);
  119. char   *     gets(char *__s);
  120. void              perror(const char *__s);
  121. int               printf(const char *__format, ...);
  122. int               puts(const char *__s);
  123. int              remove(const char *__path);
  124. int       rename(const char *__oldname,const char *__newname);
  125. void      rewind(FILE *__stream);
  126. int               scanf(const char *__format, ...);
  127. void              setbuf(FILE *__stream, char *__buf);
  128. int       setvbuf(FILE *__stream, char *__buf,
  129.                                    int __type, size_t __size);
  130. int       sprintf(char *__buffer, const char *__format, ...);
  131. int       sscanf(const char *__buffer,
  132.                                   const char *__format, ...);
  133. char   *  strerror(int __errnum);
  134. FILE   *  tmpfile(void);
  135. char   *  tmpnam(char *__s);
  136. int       ungetc(int __c, FILE *__stream);
  137. int       vfprintf(FILE *__stream, const char *__format,
  138.                                     void *__arglist);
  139. int       vfscanf(FILE *__stream, const char *__format,
  140.                                    void *__arglist);
  141. int              vprintf(const char *__format, void *__arglist);
  142. int               vscanf(const char *__format, void *__arglist);
  143. int       vsprintf(char *__buffer, const char *__format,
  144.                                     void *__arglist);
  145. int       vsscanf(const char *__buffer, const char *__format,
  146.                                    void *__arglist);
  147. int              unlink(const char *__path);
  148. int               getc(FILE *__fp);
  149.  
  150. int               getchar(void);
  151. int               putchar(const int __c);
  152.  
  153. int               putc(const int __c, FILE *__fp);
  154. int               feof(FILE *__fp);
  155. int               ferror(FILE *__fp);
  156.  
  157. int       fcloseall(void);
  158. FILE    *  fdopen(int __handle, char *__type);
  159. int       fgetchar(void);
  160. int       flushall(void);
  161. int       fputchar(int __c);
  162. FILE    *    _fsopen (const char *__path, const char *__mode,
  163.                   int __shflag);
  164. int               getw(FILE *__stream);
  165. int               putw(int __w, FILE *__stream);
  166. int               rmtmp(void);
  167. char    *   _strerror(const char *__s);
  168. char    *   tempnam(char *__dir, char *__pfx);
  169.  
  170. #define fileno(f)       ((f)->fd)
  171.  
  172. int        _fgetc(FILE *__stream);           /* used by getc() macro */
  173. int        _fputc(char __c, FILE *__stream); /* used by putc() macro */
  174. void      _InitEasyWin(void);  /* Initialization call for Easy Windows */
  175.  
  176. /*  The following macros provide for common functions */
  177.  
  178. #define ferror(f)   ((f)->flags & _F_ERR)
  179. #define feof(f)     ((f)->flags & _F_EOF)
  180.  
  181. /* These two macros donn't work yet... I have to rewrite the 
  182.  * low level I/O to handle the CR/LF thing.  Meanwhile they are written
  183.  * as functions    
  184. #define getc(f) \
  185.   ((--((f)->level) >= 0) ? (unsigned char)(*(f)->curp++) : \
  186.     _fgetc (f))
  187.  
  188. #define putc(c,f) \
  189.   ((++((f)->level) < 0) ? (unsigned char)(*(f)->curp++=(c)) : \
  190.     _fputc ((c),f))
  191. */
  192. #define getchar()  getc(stdin)
  193. #define putchar(c) putc((c), stdout)
  194.  
  195. #define ungetc(c,f) ungetc((c),f)   /* traditionally a macro */
  196.  
  197.  
  198. #endif  /* __STDIO_H */